home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
drawer.zip
/
BUTTON.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-01-04
|
2KB
|
87 lines
unit Buttons;
interface
uses MSGraph, Shape;
type
Button = object
x, y : word; { position }
xe, ye : word; { extent }
color : word; { color }
bRect : boolean; { show rectangle? }
data : shape; { what to show in button }
procedure Initialize( x, y, xe, ye, color : word; bRect : boolean; s : shape);
procedure Draw;
procedure Erase;
procedure Select;
procedure UnSelect;
function PtInRegion( px, py : word) : boolean;
end;
implementation
procedure Button.Initialize( x, y, xe, ye, color : word; bRect : boolean; s : shape);
const
XMARGIN = 4;
YMARGIN = 4;
begin
self.x := x;
self.y := y;
self.xe := xe;
self.ye := ye;
self.color := color;
self.bRect := bRect;
self.data := s;
if s<>NIL then
s.initialize( x+XMARGIN, y+YMARGIN, xe-(XMARGIN+XMARGIN), ye-(YMARGIN+YMARGIN), color);
end;
procedure Button.Draw;
begin
with self do begin
if self.bRect then begin
_SetColor(color);
_SetWriteMode(_GPSET);
_Rectangle(_GBORDER, x, y, x+xe, y+ye);
end;
if data<>NIL then data.Draw;
end;
end;
procedure Button.Erase;
begin
with self do begin
_SetColor(0);
_Rectangle(_GFILLINTERIOR, x, y, x+xe, y+ye);
end;
end;
procedure Button.Select;
begin
with self do begin
_SetColor(color);
_SetWriteMode(_GXOR);
_SetLineStyle($FFFF);
_Rectangle(_GBORDER, x+1, y+1, x+xe-1, y+ye-1);
_Rectangle(_GBORDER, x+2, y+2, x+xe-2, y+ye-2);
end;
end;
procedure Button.UnSelect;
begin
self.Select;
end;
function Button.PtInRegion( px, py : word) : boolean;
begin
with self do
PtInRegion := (px>=x) and (px<=(x+xe)) and
(py>=y) and (py<=(y+ye));
end;
begin
end.